package com.iknow.image;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import com.iknow.IKnow;
import com.iknow.file.CacheSystem;
import com.iknow.util.LogUtil;
import com.iknow.util.Loger;
import com.iknow.util.StringUtil;
import com.iknow.util.SystemUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;

public class ImageManager
  implements ImageCache
{
  private static final int CONNECTION_TIMEOUT_MS = 10000;
  public static final int DEFAULT_COMPRESS_QUALITY = 90;
  public static final int IMAGE_MAX_SIZE = 496;
  public static final int MAX_HEIGHT = 320;
  public static final int MAX_WIDTH = 240;
  private static final int SOCKET_TIMEOUT_MS = 10000;
  private static final String TAG = "ImageManager";
  private Map<String, SoftReference<Bitmap>> mCache;
  private File mCachePath = null;
  private HttpClient mClient;
  private Context mContext;
  private MessageDigest mDigest;

  public ImageManager(Context paramContext)
  {
    this.mContext = paramContext;
    this.mCache = new HashMap();
    this.mClient = new DefaultHttpClient();
    this.mCachePath = new File(SystemUtil.fillSDPath("cache" + File.separator));
    try
    {
      this.mDigest = MessageDigest.getInstance("MD5");
      return;
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      throw new RuntimeException("No MD5 algorithm.");
    }
  }

  private File createCacheFile(String paramString)
  {
    File localFile;
    try
    {
      localFile = new File(IKnow.mCacheSystem.getImagePath() + paramString);
      return localFile;
    }
    catch (Exception localException)
    {
      LogUtil.e(super.getClass(), localException);
      throw new RuntimeException("Can Not Found SD Card !!!");
    }
  }

  private String getHashString(MessageDigest paramMessageDigest)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    byte[] arrayOfByte = paramMessageDigest.digest();
    int i = arrayOfByte.length;
    int j = 0;
    while (true)
    {
      if (j >= i)
        return localStringBuilder.toString();
      int k = arrayOfByte[j];
      localStringBuilder.append(Integer.toHexString(0xF & k >> 4));
      localStringBuilder.append(Integer.toHexString(k & 0xF));
      ++j;
    }
  }

  private String getMd5(String paramString)
  {
    this.mDigest.update(paramString.getBytes());
    return getHashString(this.mDigest);
  }

  // ERROR //
  private Bitmap lookupFile(String paramString)
  {
    // Byte code:
    //   0: aload_1
    //   1: invokestatic 166	com/iknow/util/StringUtil:isEmpty	(Ljava/lang/String;)Z
    //   4: ifeq +9 -> 13
    //   7: aconst_null
    //   8: astore 10
    //   10: aload 10
    //   12: areturn
    //   13: aload_0
    //   14: aload_1
    //   15: iconst_1
    //   16: aload_1
    //   17: ldc 168
    //   19: invokevirtual 172	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   22: iadd
    //   23: aload_1
    //   24: invokevirtual 176	java/lang/String:length	()I
    //   27: invokevirtual 180	java/lang/String:substring	(II)Ljava/lang/String;
    //   30: invokespecial 182	com/iknow/image/ImageManager:getMd5	(Ljava/lang/String;)Ljava/lang/String;
    //   33: astore_2
    //   34: aconst_null
    //   35: astore_3
    //   36: new 56	java/io/File
    //   39: dup
    //   40: new 58	java/lang/StringBuilder
    //   43: dup
    //   44: getstatic 106	com/iknow/IKnow:mCacheSystem	Lcom/iknow/file/CacheSystem;
    //   47: invokevirtual 111	com/iknow/file/CacheSystem:getImagePath	()Ljava/lang/String;
    //   50: invokestatic 117	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   53: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   56: aload_2
    //   57: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   60: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   63: invokespecial 81	java/io/File:<init>	(Ljava/lang/String;)V
    //   66: astore 4
    //   68: aload 4
    //   70: invokevirtual 186	java/io/File:exists	()Z
    //   73: ifne +9 -> 82
    //   76: aconst_null
    //   77: astore 10
    //   79: goto -69 -> 10
    //   82: new 188	android/graphics/BitmapFactory$Options
    //   85: dup
    //   86: invokespecial 189	android/graphics/BitmapFactory$Options:<init>	()V
    //   89: astore 5
    //   91: aload 5
    //   93: iconst_1
    //   94: putfield 193	android/graphics/BitmapFactory$Options:inJustDecodeBounds	Z
    //   97: new 195	java/io/FileInputStream
    //   100: dup
    //   101: aload 4
    //   103: invokespecial 198	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   106: astore 21
    //   108: aload 21
    //   110: aconst_null
    //   111: aload 5
    //   113: invokestatic 204	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
    //   116: pop
    //   117: aload 21
    //   119: invokevirtual 207	java/io/FileInputStream:close	()V
    //   122: new 188	android/graphics/BitmapFactory$Options
    //   125: dup
    //   126: invokespecial 189	android/graphics/BitmapFactory$Options:<init>	()V
    //   129: astore 27
    //   131: aload 27
    //   133: iconst_1
    //   134: putfield 210	android/graphics/BitmapFactory$Options:inSampleSize	I
    //   137: new 195	java/io/FileInputStream
    //   140: dup
    //   141: aload 4
    //   143: invokespecial 198	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   146: astore_3
    //   147: aload_3
    //   148: aconst_null
    //   149: aload 27
    //   151: invokestatic 204	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
    //   154: astore 28
    //   156: aload_3
    //   157: ifnull +7 -> 164
    //   160: aload_3
    //   161: invokevirtual 207	java/io/FileInputStream:close	()V
    //   164: aload 28
    //   166: astore 10
    //   168: goto -158 -> 10
    //   171: astore 18
    //   173: aload 18
    //   175: astore 19
    //   177: ldc 22
    //   179: new 58	java/lang/StringBuilder
    //   182: dup
    //   183: ldc 212
    //   185: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   188: aload 19
    //   190: invokevirtual 215	java/io/FileNotFoundException:getMessage	()Ljava/lang/String;
    //   193: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   196: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   199: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   202: aload_3
    //   203: ifnull +7 -> 210
    //   206: aload_3
    //   207: invokevirtual 207	java/io/FileInputStream:close	()V
    //   210: aconst_null
    //   211: astore 10
    //   213: goto -203 -> 10
    //   216: astore 15
    //   218: aload 15
    //   220: astore 16
    //   222: ldc 22
    //   224: new 58	java/lang/StringBuilder
    //   227: dup
    //   228: ldc 212
    //   230: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   233: aload 16
    //   235: invokevirtual 222	java/lang/RuntimeException:getMessage	()Ljava/lang/String;
    //   238: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   241: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   244: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   247: aload_3
    //   248: ifnull +7 -> 255
    //   251: aload_3
    //   252: invokevirtual 207	java/io/FileInputStream:close	()V
    //   255: aconst_null
    //   256: astore 10
    //   258: goto -248 -> 10
    //   261: astore 12
    //   263: aload 12
    //   265: astore 13
    //   267: ldc 22
    //   269: new 58	java/lang/StringBuilder
    //   272: dup
    //   273: ldc 212
    //   275: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   278: aload 13
    //   280: invokevirtual 223	java/lang/Exception:getMessage	()Ljava/lang/String;
    //   283: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   286: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   289: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   292: aload_3
    //   293: ifnull +7 -> 300
    //   296: aload_3
    //   297: invokevirtual 207	java/io/FileInputStream:close	()V
    //   300: aconst_null
    //   301: astore 10
    //   303: goto -293 -> 10
    //   306: astore 8
    //   308: aload 8
    //   310: astore 9
    //   312: ldc 22
    //   314: new 58	java/lang/StringBuilder
    //   317: dup
    //   318: ldc 212
    //   320: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   323: aload 9
    //   325: invokevirtual 224	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   328: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   331: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   334: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   337: aload_3
    //   338: ifnull +7 -> 345
    //   341: aload_3
    //   342: invokevirtual 207	java/io/FileInputStream:close	()V
    //   345: aconst_null
    //   346: astore 10
    //   348: goto -338 -> 10
    //   351: astore 6
    //   353: aload_3
    //   354: ifnull +7 -> 361
    //   357: aload_3
    //   358: invokevirtual 207	java/io/FileInputStream:close	()V
    //   361: aload 6
    //   363: athrow
    //   364: astore 29
    //   366: goto -202 -> 164
    //   369: astore 20
    //   371: goto -161 -> 210
    //   374: astore 17
    //   376: goto -121 -> 255
    //   379: astore 14
    //   381: goto -81 -> 300
    //   384: astore 11
    //   386: goto -41 -> 345
    //   389: astore 7
    //   391: goto -30 -> 361
    //   394: astore 6
    //   396: aload 21
    //   398: astore_3
    //   399: goto -46 -> 353
    //   402: astore 25
    //   404: aload 25
    //   406: astore 9
    //   408: aload 21
    //   410: astore_3
    //   411: goto -99 -> 312
    //   414: astore 24
    //   416: aload 24
    //   418: astore 13
    //   420: aload 21
    //   422: astore_3
    //   423: goto -156 -> 267
    //   426: astore 23
    //   428: aload 23
    //   430: astore 16
    //   432: aload 21
    //   434: astore_3
    //   435: goto -213 -> 222
    //   438: astore 22
    //   440: aload 22
    //   442: astore 19
    //   444: aload 21
    //   446: astore_3
    //   447: goto -270 -> 177
    //
    // Exception table:
    //   from	to	target	type
    //   82	108	171	java/io/FileNotFoundException
    //   147	156	171	java/io/FileNotFoundException
    //   82	108	216	java/lang/RuntimeException
    //   147	156	216	java/lang/RuntimeException
    //   82	108	261	java/lang/Exception
    //   147	156	261	java/lang/Exception
    //   82	108	306	java/lang/Throwable
    //   147	156	306	java/lang/Throwable
    //   82	108	351	finally
    //   147	156	351	finally
    //   177	202	351	finally
    //   222	247	351	finally
    //   267	292	351	finally
    //   312	337	351	finally
    //   160	164	364	java/io/IOException
    //   206	210	369	java/io/IOException
    //   251	255	374	java/io/IOException
    //   296	300	379	java/io/IOException
    //   341	345	384	java/io/IOException
    //   357	361	389	java/io/IOException
    //   108	147	394	finally
    //   108	147	402	java/lang/Throwable
    //   108	147	414	java/lang/Exception
    //   108	147	426	java/lang/RuntimeException
    //   108	147	438	java/io/FileNotFoundException
  }

  private void writeFile(String paramString, Bitmap paramBitmap, int paramInt)
  {
    FileOutputStream localFileOutputStream;
    if (paramBitmap == null)
    {
      Loger.w("ImageManager", "Can't write file. Bitmap is null.");
      return;
    }
    int i = paramString.indexOf("?");
    String str1 = paramString;
    if (-1 != i)
      str1 = paramString.substring(i + 1, str1.length());
    String str2 = getMd5(str1);
    File localFile = createCacheFile(str2);
    try
    {
      localFileOutputStream = new FileOutputStream(localFile);
      if ((paramBitmap.getWidth() < 100) && (paramBitmap.getHeight() < 100))
        paramInt = 100;
      Loger.i("ImageManager", "Writing file: " + str2);
    }
    catch (Exception localException)
    {
      try
      {
        paramBitmap.compress(Bitmap.CompressFormat.JPEG, paramInt, localFileOutputStream);
      }
      catch (Exception localException)
      {
        try
        {
          localFileOutputStream.close();
        }
        catch (IOException localIOException)
        {
          while (true)
          {
            while (true)
            {
              while (true)
                Loger.w("ImageManager", "Could not close file.");
              localFileNotFoundException = localFileNotFoundException;
              Loger.w("ImageManager", "Error creating file.");
            }
            localException = localException;
            Loger.w("ImageManager", "Could not compress file.");
          }
        }
      }
    }
  }

  public File bitmapToFile(Bitmap paramBitmap, String paramString)
  {
    File localFile2;
    File localFile1 = new File(paramString);
    try
    {
      FileOutputStream localFileOutputStream = new FileOutputStream(localFile1);
      if (paramBitmap.compress(Bitmap.CompressFormat.JPEG, 80, localFileOutputStream))
      {
        localFileOutputStream.flush();
        localFileOutputStream.close();
      }
      localFile2 = localFile1;
      return localFile2;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      Loger.e("ImageManager", "Sorry, the file can not be created");
      localFile2 = null;
    }
    catch (IOException localIOException)
    {
      Loger.e("ImageManager", "IOException occurred when save upload file");
      localFile2 = null;
    }
  }

  public void cleanup(HashSet<String> paramHashSet)
  {
    int i;
    int j;
    String[] arrayOfString = this.mContext.fileList();
    HashSet localHashSet = new HashSet();
    Iterator localIterator = paramHashSet.iterator();
    if (!(localIterator.hasNext()))
    {
      i = arrayOfString.length;
      j = 0;
    }
    while (true)
    {
      while (j >= i)
      {
        return;
        localHashSet.add(getMd5((String)localIterator.next()));
      }
      String str = arrayOfString[j];
      if (!(localHashSet.contains(str)))
      {
        Loger.i("ImageManager", "Deleting unused file: " + str);
        this.mContext.deleteFile(str);
      }
      ++j;
    }
  }

  // ERROR //
  public void clear()
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   6: invokeinterface 317 1 0
    //   11: invokeinterface 320 1 0
    //   16: astore_2
    //   17: iconst_0
    //   18: istore_3
    //   19: aload_2
    //   20: invokeinterface 294 1 0
    //   25: ifne +58 -> 83
    //   28: iconst_2
    //   29: anewarray 4	java/lang/Object
    //   32: astore 6
    //   34: aload 6
    //   36: iconst_0
    //   37: iload_3
    //   38: invokestatic 323	java/lang/Integer:valueOf	(I)Ljava/lang/Integer;
    //   41: aastore
    //   42: aload 6
    //   44: iconst_1
    //   45: aload_0
    //   46: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   49: invokeinterface 326 1 0
    //   54: invokestatic 323	java/lang/Integer:valueOf	(I)Ljava/lang/Integer;
    //   57: aastore
    //   58: ldc 22
    //   60: ldc_w 328
    //   63: aload 6
    //   65: invokestatic 332	java/lang/String:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   68: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   71: aload_0
    //   72: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   75: invokeinterface 334 1 0
    //   80: aload_0
    //   81: monitorexit
    //   82: return
    //   83: aload_2
    //   84: invokeinterface 298 1 0
    //   89: checkcast 336	java/util/Map$Entry
    //   92: astore 4
    //   94: aload 4
    //   96: invokeinterface 339 1 0
    //   101: checkcast 341	java/lang/ref/SoftReference
    //   104: invokevirtual 344	java/lang/ref/SoftReference:get	()Ljava/lang/Object;
    //   107: checkcast 238	android/graphics/Bitmap
    //   110: astore 5
    //   112: aload 5
    //   114: ifnull -95 -> 19
    //   117: aload 5
    //   119: invokevirtual 347	android/graphics/Bitmap:isRecycled	()Z
    //   122: ifne -103 -> 19
    //   125: aload 5
    //   127: invokevirtual 350	android/graphics/Bitmap:recycle	()V
    //   130: iinc 3 1
    //   133: ldc 22
    //   135: new 58	java/lang/StringBuilder
    //   138: dup
    //   139: ldc_w 352
    //   142: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   145: aload 4
    //   147: invokeinterface 355 1 0
    //   152: invokevirtual 358	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   155: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   158: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   161: goto -142 -> 19
    //   164: astore_1
    //   165: aload_0
    //   166: monitorexit
    //   167: aload_1
    //   168: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   2	167	164	finally
  }

  public File compressImage(File paramFile, int paramInt)
    throws IOException
  {
    put(paramFile, paramInt, true);
    String str = getMd5(paramFile.getPath());
    return new File(IKnow.mCacheSystem.getImagePath() + str);
  }

  public boolean contains(String paramString)
  {
    int i;
    if (get(paramString) != mDefaultBitmap)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  // ERROR //
  public Bitmap createThumbnailBitmap(android.net.Uri paramUri, int paramInt)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aload_0
    //   3: getfield 44	com/iknow/image/ImageManager:mContext	Landroid/content/Context;
    //   6: invokevirtual 379	android/content/Context:getContentResolver	()Landroid/content/ContentResolver;
    //   9: aload_1
    //   10: invokevirtual 385	android/content/ContentResolver:openInputStream	(Landroid/net/Uri;)Ljava/io/InputStream;
    //   13: astore_3
    //   14: new 188	android/graphics/BitmapFactory$Options
    //   17: dup
    //   18: invokespecial 189	android/graphics/BitmapFactory$Options:<init>	()V
    //   21: astore 9
    //   23: aload 9
    //   25: iconst_1
    //   26: putfield 193	android/graphics/BitmapFactory$Options:inJustDecodeBounds	Z
    //   29: aload_3
    //   30: aconst_null
    //   31: aload 9
    //   33: invokestatic 204	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
    //   36: pop
    //   37: aload_3
    //   38: invokevirtual 388	java/io/InputStream:close	()V
    //   41: iconst_1
    //   42: istore 11
    //   44: aload 9
    //   46: getfield 391	android/graphics/BitmapFactory$Options:outWidth	I
    //   49: iload 11
    //   51: idiv
    //   52: iload_2
    //   53: if_icmpgt +64 -> 117
    //   56: aload 9
    //   58: getfield 394	android/graphics/BitmapFactory$Options:outHeight	I
    //   61: iload 11
    //   63: idiv
    //   64: iload_2
    //   65: if_icmpgt +52 -> 117
    //   68: aload 9
    //   70: iconst_0
    //   71: putfield 193	android/graphics/BitmapFactory$Options:inJustDecodeBounds	Z
    //   74: aload 9
    //   76: iload 11
    //   78: putfield 210	android/graphics/BitmapFactory$Options:inSampleSize	I
    //   81: aload_0
    //   82: getfield 44	com/iknow/image/ImageManager:mContext	Landroid/content/Context;
    //   85: invokevirtual 379	android/content/Context:getContentResolver	()Landroid/content/ContentResolver;
    //   88: aload_1
    //   89: invokevirtual 385	android/content/ContentResolver:openInputStream	(Landroid/net/Uri;)Ljava/io/InputStream;
    //   92: astore_3
    //   93: aload_3
    //   94: aconst_null
    //   95: aload 9
    //   97: invokestatic 204	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
    //   100: astore 12
    //   102: aload 12
    //   104: astore 7
    //   106: aload_3
    //   107: ifnull +7 -> 114
    //   110: aload_3
    //   111: invokevirtual 388	java/io/InputStream:close	()V
    //   114: aload 7
    //   116: areturn
    //   117: iload 11
    //   119: iconst_2
    //   120: imul
    //   121: istore 11
    //   123: goto -79 -> 44
    //   126: astore 13
    //   128: ldc 22
    //   130: aload 13
    //   132: invokestatic 397	com/iknow/util/Loger:w	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   135: goto -21 -> 114
    //   138: astore 6
    //   140: ldc 22
    //   142: aload 6
    //   144: invokestatic 397	com/iknow/util/Loger:w	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   147: aload_3
    //   148: ifnull +7 -> 155
    //   151: aload_3
    //   152: invokevirtual 388	java/io/InputStream:close	()V
    //   155: aconst_null
    //   156: astore 7
    //   158: goto -44 -> 114
    //   161: astore 8
    //   163: ldc 22
    //   165: aload 8
    //   167: invokestatic 397	com/iknow/util/Loger:w	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   170: goto -15 -> 155
    //   173: astore 4
    //   175: aload_3
    //   176: ifnull +7 -> 183
    //   179: aload_3
    //   180: invokevirtual 388	java/io/InputStream:close	()V
    //   183: aload 4
    //   185: athrow
    //   186: astore 5
    //   188: ldc 22
    //   190: aload 5
    //   192: invokestatic 397	com/iknow/util/Loger:w	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   195: goto -12 -> 183
    //
    // Exception table:
    //   from	to	target	type
    //   110	114	126	IOException
    //   2	102	138	IOException
    //   151	155	161	IOException
    //   2	102	173	finally
    //   140	147	173	finally
    //   179	183	186	IOException
  }

  // ERROR //
  public Bitmap fetchImage(String paramString)
    throws IOException
  {
    // Byte code:
    //   0: ldc 22
    //   2: new 58	java/lang/StringBuilder
    //   5: dup
    //   6: ldc_w 400
    //   9: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   12: aload_1
    //   13: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   16: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   19: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   22: aload_1
    //   23: ldc_w 402
    //   26: ldc_w 404
    //   29: invokevirtual 408	java/lang/String:replace	(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
    //   32: astore_2
    //   33: aconst_null
    //   34: astore_3
    //   35: aconst_null
    //   36: astore 4
    //   38: getstatic 412	com/iknow/IKnow:mApi	Lcom/iknow/IKnowApiV4;
    //   41: aload_2
    //   42: iconst_0
    //   43: invokevirtual 417	com/iknow/IKnowApiV4:get	(Ljava/lang/String;Z)Lcom/iknow/http/Response;
    //   46: invokevirtual 423	com/iknow/http/Response:asStream	()Ljava/io/InputStream;
    //   49: astore 4
    //   51: aload 4
    //   53: invokestatic 426	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;)Landroid/graphics/Bitmap;
    //   56: astore 8
    //   58: aload 8
    //   60: astore_3
    //   61: aload 4
    //   63: ifnull +8 -> 71
    //   66: aload 4
    //   68: invokevirtual 388	java/io/InputStream:close	()V
    //   71: aload_3
    //   72: areturn
    //   73: astore 7
    //   75: ldc 22
    //   77: aload 7
    //   79: invokevirtual 223	java/lang/Exception:getMessage	()Ljava/lang/String;
    //   82: invokestatic 272	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   85: aload 4
    //   87: ifnull -16 -> 71
    //   90: aload 4
    //   92: invokevirtual 388	java/io/InputStream:close	()V
    //   95: goto -24 -> 71
    //   98: astore 6
    //   100: ldc 22
    //   102: aload 6
    //   104: invokevirtual 224	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   107: invokestatic 272	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   110: aload 4
    //   112: ifnull -41 -> 71
    //   115: aload 4
    //   117: invokevirtual 388	java/io/InputStream:close	()V
    //   120: goto -49 -> 71
    //   123: astore 5
    //   125: aload 4
    //   127: ifnull +8 -> 135
    //   130: aload 4
    //   132: invokevirtual 388	java/io/InputStream:close	()V
    //   135: aload 5
    //   137: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   38	58	73	java/lang/Exception
    //   38	58	98	java/lang/Throwable
    //   38	58	123	finally
    //   75	85	123	finally
    //   100	110	123	finally
  }

  public Bitmap get(File paramFile)
  {
    return get(paramFile.getPath());
  }

  // ERROR //
  public Bitmap get(String paramString)
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   6: aload_1
    //   7: invokeinterface 430 2 0
    //   12: checkcast 341	java/lang/ref/SoftReference
    //   15: astore_3
    //   16: aload_0
    //   17: monitorexit
    //   18: aload_3
    //   19: ifnull +29 -> 48
    //   22: aload_3
    //   23: invokevirtual 344	java/lang/ref/SoftReference:get	()Ljava/lang/Object;
    //   26: checkcast 238	android/graphics/Bitmap
    //   29: astore 8
    //   31: aload 8
    //   33: ifnull +15 -> 48
    //   36: aload 8
    //   38: astore 5
    //   40: aload 5
    //   42: areturn
    //   43: astore_2
    //   44: aload_0
    //   45: monitorexit
    //   46: aload_2
    //   47: athrow
    //   48: aload_0
    //   49: aload_1
    //   50: invokespecial 432	com/iknow/image/ImageManager:lookupFile	(Ljava/lang/String;)Landroid/graphics/Bitmap;
    //   53: astore 4
    //   55: aload 4
    //   57: ifnull +41 -> 98
    //   60: aload_0
    //   61: monitorenter
    //   62: aload_0
    //   63: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   66: aload_1
    //   67: new 341	java/lang/ref/SoftReference
    //   70: dup
    //   71: aload 4
    //   73: invokespecial 435	java/lang/ref/SoftReference:<init>	(Ljava/lang/Object;)V
    //   76: invokeinterface 438 3 0
    //   81: pop
    //   82: aload_0
    //   83: monitorexit
    //   84: aload 4
    //   86: astore 5
    //   88: goto -48 -> 40
    //   91: astore 6
    //   93: aload_0
    //   94: monitorexit
    //   95: aload 6
    //   97: athrow
    //   98: ldc 22
    //   100: new 58	java/lang/StringBuilder
    //   103: dup
    //   104: ldc_w 440
    //   107: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   110: aload_1
    //   111: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   114: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   117: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   120: getstatic 373	com/iknow/image/ImageManager:mDefaultBitmap	Landroid/graphics/Bitmap;
    //   123: astore 5
    //   125: goto -85 -> 40
    //
    // Exception table:
    //   from	to	target	type
    //   2	18	43	finally
    //   44	46	43	finally
    //   62	95	91	finally
  }

  public int getCacheBitmapSize()
  {
    return this.mCache.size();
  }

  // ERROR //
  public Bitmap getFromLocal(String paramString)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aload_0
    //   3: monitorenter
    //   4: aload_0
    //   5: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   8: aload_1
    //   9: invokeinterface 430 2 0
    //   14: checkcast 341	java/lang/ref/SoftReference
    //   17: astore 4
    //   19: aload_0
    //   20: monitorexit
    //   21: aload 4
    //   23: ifnull +27 -> 50
    //   26: aload 4
    //   28: invokevirtual 344	java/lang/ref/SoftReference:get	()Ljava/lang/Object;
    //   31: checkcast 238	android/graphics/Bitmap
    //   34: astore_2
    //   35: aload_2
    //   36: ifnull +14 -> 50
    //   39: aload_2
    //   40: astore 7
    //   42: aload 7
    //   44: areturn
    //   45: astore_3
    //   46: aload_0
    //   47: monitorexit
    //   48: aload_3
    //   49: athrow
    //   50: ldc 22
    //   52: new 58	java/lang/StringBuilder
    //   55: dup
    //   56: ldc_w 444
    //   59: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   62: aload_1
    //   63: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   66: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   69: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   72: new 56	java/io/File
    //   75: dup
    //   76: aload_1
    //   77: invokespecial 81	java/io/File:<init>	(Ljava/lang/String;)V
    //   80: astore 5
    //   82: aload 5
    //   84: invokevirtual 186	java/io/File:exists	()Z
    //   87: ifne +9 -> 96
    //   90: aconst_null
    //   91: astore 7
    //   93: goto -51 -> 42
    //   96: new 195	java/io/FileInputStream
    //   99: dup
    //   100: aload 5
    //   102: invokespecial 198	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   105: invokestatic 426	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;)Landroid/graphics/Bitmap;
    //   108: astore 10
    //   110: aload 10
    //   112: astore_2
    //   113: aload_2
    //   114: ifnull +71 -> 185
    //   117: aload_0
    //   118: monitorenter
    //   119: aload_0
    //   120: getfield 49	com/iknow/image/ImageManager:mCache	Ljava/util/Map;
    //   123: aload_1
    //   124: new 341	java/lang/ref/SoftReference
    //   127: dup
    //   128: aload_2
    //   129: invokespecial 435	java/lang/ref/SoftReference:<init>	(Ljava/lang/Object;)V
    //   132: invokeinterface 438 3 0
    //   137: pop
    //   138: aload_0
    //   139: monitorexit
    //   140: aload_2
    //   141: astore 7
    //   143: goto -101 -> 42
    //   146: astore 6
    //   148: ldc 22
    //   150: new 58	java/lang/StringBuilder
    //   153: dup
    //   154: ldc_w 440
    //   157: invokespecial 63	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   160: aload_1
    //   161: invokevirtual 70	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   164: invokevirtual 74	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   167: invokestatic 221	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   170: aload 6
    //   172: invokevirtual 447	java/io/FileNotFoundException:printStackTrace	()V
    //   175: goto -62 -> 113
    //   178: astore 8
    //   180: aload_0
    //   181: monitorexit
    //   182: aload 8
    //   184: athrow
    //   185: aconst_null
    //   186: astore 7
    //   188: goto -146 -> 42
    //
    // Exception table:
    //   from	to	target	type
    //   4	21	45	finally
    //   46	48	45	finally
    //   96	110	146	java/io/FileNotFoundException
    //   119	140	178	finally
    //   180	182	178	finally
  }

  public String getLocalImagePath(String paramString)
  {
    Object localObject;
    if (StringUtil.isEmpty(paramString))
      localObject = null;
    while (true)
    {
      return localObject;
      String str1 = null;
      String str2 = getMd5(paramString.substring(1 + paramString.indexOf("?"), paramString.length()));
      File localFile = new File(IKnow.mCacheSystem.getImagePath() + str2);
      if (localFile.exists())
        str1 = localFile.getAbsolutePath();
      localObject = str1;
    }
  }

  public InputStream getUngzippedContent(HttpEntity paramHttpEntity)
    throws IOException
  {
    Object localObject2;
    Object localObject1 = paramHttpEntity.getContent();
    if (localObject1 == null)
      localObject2 = localObject1;
    while (true)
    {
      String str;
      while (true)
      {
        Header localHeader;
        while (true)
        {
          return localObject2;
          localHeader = paramHttpEntity.getContentEncoding();
          if (localHeader != null)
            break;
          localObject2 = localObject1;
        }
        str = localHeader.getValue();
        if (str != null)
          break;
        localObject2 = localObject1;
      }
      if (str.contains("gzip"))
        localObject1 = new GZIPInputStream((InputStream)localObject1);
      localObject2 = localObject1;
    }
  }

  public void put(File paramFile, int paramInt, boolean paramBoolean)
    throws IOException
  {
    if (!(paramFile.exists()))
      Loger.w("ImageManager", paramFile.getName() + " is not exists.");
    while (true)
    {
      Bitmap localBitmap;
      while (true)
      {
        while (true)
        {
          return;
          if ((paramBoolean) || (!(contains(paramFile.getPath()))))
            break;
          Loger.i("ImageManager", paramFile.getName() + " is exists");
        }
        localBitmap = resizeBitmap(BitmapFactory.decodeFile(paramFile.getPath()), 240, 320);
        if (localBitmap != null)
          break;
        Loger.w("ImageManager", "Retrieved bitmap is null.");
      }
      put(paramFile.getPath(), localBitmap, paramInt);
    }
  }

  public void put(String paramString)
    throws IOException
  {
    put(paramString, 90, false);
  }

  public void put(String paramString, int paramInt, boolean paramBoolean)
    throws IOException
  {
    if ((!(paramBoolean)) && (contains(paramString)))
      return;
    Object localObject = null;
    try
    {
      Bitmap localBitmap = fetchImage(paramString);
      localObject = localBitmap;
      if (localObject == null)
        Loger.w("ImageManager", "Retrieved bitmap is null.");
    }
    catch (IOException localIOException)
    {
      while (true)
        Loger.e("ImageManager", localIOException.getMessage());
    }
    catch (Exception localException)
    {
      while (true)
        Loger.e("ImageManager", localException.getMessage());
      put(paramString, localObject, paramInt);
    }
  }

  public void put(String paramString, Bitmap paramBitmap)
  {
    put(paramString, paramBitmap, 90);
  }

  public void put(String paramString, Bitmap paramBitmap, int paramInt)
  {
    monitorenter;
    try
    {
      this.mCache.put(paramString, new SoftReference(paramBitmap));
      monitorexit;
      return;
    }
    finally
    {
      monitorexit;
    }
  }

  public void recycleBitmap(String paramString)
  {
    SoftReference localSoftReference = (SoftReference)this.mCache.get(paramString);
    if (localSoftReference != null)
    {
      Bitmap localBitmap = (Bitmap)localSoftReference.get();
      if ((localBitmap != null) && (!(localBitmap.isRecycled())))
      {
        localBitmap.recycle();
        Loger.i("ImageManager", "recycleBitmap--" + paramString);
      }
      this.mCache.remove(paramString);
    }
  }

  public void recycleBitmap(List<String> paramList)
  {
    Iterator localIterator = paramList.iterator();
    while (true)
    {
      String str;
      SoftReference localSoftReference;
      do
      {
        if (!(localIterator.hasNext()))
          return;
        str = (String)localIterator.next();
        localSoftReference = (SoftReference)this.mCache.get(str);
      }
      while (localSoftReference == null);
      Bitmap localBitmap = (Bitmap)localSoftReference.get();
      if ((localBitmap != null) && (!(localBitmap.isRecycled())))
      {
        Loger.i("ImageManager", "bitmap recycle: " + str);
        localBitmap.recycle();
      }
      this.mCache.remove(str);
    }
  }

  public Bitmap resizeBitmap(Bitmap paramBitmap, int paramInt1, int paramInt2)
  {
    Bitmap localBitmap;
    int i = paramBitmap.getWidth();
    int j = paramBitmap.getHeight();
    if ((i < paramInt1) && (j < paramInt2))
      localBitmap = paramBitmap;
    while (true)
    {
      return localBitmap;
      int k = i;
      int l = j;
      if (i > paramInt1)
      {
        k = paramInt1;
        double d = 1D * i / paramInt1;
        l = (int)Math.floor(j / d);
        paramBitmap = Bitmap.createScaledBitmap(paramBitmap, k, l, false);
      }
      if (l > paramInt2)
        paramBitmap = Bitmap.createBitmap(paramBitmap, 0, 0, k, paramInt2);
      localBitmap = paramBitmap;
    }
  }

  public void setContext(Context paramContext)
  {
    this.mContext = paramContext;
  }
}